<template>
  <div class="home_warp">
    <el-card>
      <el-table
        :data="rolesList"
        style="width: 100%"
        border
        :header-cell-style="{ textAlign: 'center' }"
        :cell-style="{ textAlign: 'center' }"
      >
        <el-table-column width="80" type="index" label="#"> </el-table-column>
        <el-table-column prop="authName" label="权限名称"> </el-table-column>
        <el-table-column prop="id" label="权限 ID"> </el-table-column>
        <el-table-column prop="pid" label="权限父ID"> </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template v-slot="{ row }">
            <el-tag class="level-tag" v-if="row.level === '0'">一级</el-tag>
            <el-tag
              class="level-tag"
              v-else-if="row.level === '1'"
              type="success"
              >二级</el-tag
            >
            <el-tag class="level-tag" v-else-if="row.level === '2'" type="info"
              >三级</el-tag
            >
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
import { allRoles } from '@/api/role'
export default {
  name: 'RoleList',
  data() {
    return {
      rolesList: []
    }
  },
  methods: {
    async getAllRolesList() {
      const { data: res } = await allRoles('list')
      console.log(res)
      this.rolesList = res
    }
  },
  created() {
    this.getAllRolesList()
  }
}
</script>
<style lang="scss" scoped>
.level-tag {
  width: 100px;
  height: 40px;
  line-height: 40px;
  font-size: 20px;
}
</style>
